<%# -*- javascript -*- %>
var treeView = new TreeView(<%= tree_id.to_json %>,
                            {
                              move: false,
                              emptyImg: true,
                              open: true
                            });

treeView.addSelectItemCallback(function (element)
{
  var selectedNode = element.getElementsByClassName('node-dn')[0];
  var selectedDN = selectedNode.childNodes[0].nodeValue;
  var failureHandler = function(transport, json)
  {
    var message = <%= failed_to_retrieve_entry_message.to_json %> + "\n";
    message += '<span class="dn">' + selectedDN + "</span>\n";
    message = "<div class=\"entry\">\n" + message + "</div>";
    $(<%= entry_id.to_json %>).update(message);
  }

  <%= remote_function(:update => {:success => entry_id},
                      :url => url_for(:action => "entry"),
                      :with => "'dn=' + selectedDN",
                      :failure => "failureHandler") %>;
});
